#include "loop_queue.h"

int main(int argc, const char *argv[]){
    queue_t *my_queue = NULL;
    create_queue(&my_queue);
    printf("my_queue = %p\n", my_queue); // 非NULL

    // 入队列
    push_queue(my_queue, 10);
    push_queue(my_queue, 20);
    push_queue(my_queue, 30);
    push_queue(my_queue, 40);
    push_queue(my_queue, 50); // 满了 失败
    print_queue(my_queue); // 10 20 30 40

    // 出队列
    int value = 0;
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 10
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 20
    print_queue(my_queue); // 30 40

    // 入队列
    push_queue(my_queue, 100);
    push_queue(my_queue, 200);
    push_queue(my_queue, 300); // 满了 失败
    print_queue(my_queue); // 30 40 100 200

    // 出队列
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 30
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 40
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 100
    pop_queue(my_queue, &value);
    printf("value = %d\n", value); // 200
    pop_queue(my_queue, &value); // 空 失败

    // 入队列
    push_queue(my_queue, 70);
    push_queue(my_queue, 80);
    print_queue(my_queue); // 70 80
    
    // 清空
    clean_queue(my_queue);
    print_queue(my_queue); // 没有元素了

    // 销毁
    destroy_queue(&my_queue);
    printf("my_queue = %p\n", my_queue); // NULL

    return 0;
}